package com.jk.smartelderlycare.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jk.smartelderlycare.dao.SysGoodsMapper;
import com.jk.smartelderlycare.dto.SysGoods;
import com.jk.smartelderlycare.pojo.PagedResponse;
import com.jk.smartelderlycare.service.SysGoodsService;
import com.jk.smartelderlycare.utils.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author hhk
 * @version 1.0
 * @ClassName SysGoodsServiceImpl
 * @program: smart-elderly-care
 * @description: TODO
 * @date 2024/12/5 10:47
 */
@Service
public class SysGoodsServiceImpl implements SysGoodsService {
    @Autowired
    private SysGoodsMapper sysGoodsMapper;
        /**
         * @description: 后端分页查询
         * @param: [sysGoods, pageNum, pageSize]
         * @return: com.jk.smartelderlycare.pojo.PagedResponse<com.jk.smartelderlycare.dto.SysGoods>
         * @author hhk
         * @date: 2024/12/5 10:49
         */
    @Override
    public PagedResponse<SysGoods> findSysGoodsPaginationList(SysGoods sysGoods, Integer pageNum, Integer pageSize) {
        Page<SysGoods> page = new Page<>();
      IPage<SysGoods> goodsIPage =  sysGoodsMapper.findSysGoodsPaginationList(sysGoods,page);
        return PaginationUtil.getPagedResponse(goodsIPage.getRecords(),pageNum,pageSize,goodsIPage.getTotal());
    }
    /**
     * @description: 导出
     * @param: []
     * @return: java.util.List<com.jk.smartelderlycare.dto.SysGoods>
     * @author hhk
     * @date: 2024/12/5 10:49
     */
    @Override
    public List<SysGoods> findSysGoodsList() {
        return sysGoodsMapper.selectList(null);
    }
}
